<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>

    <body>

        <button id="test">测试签名</button>
        <script src="https://cdn.bootcss.com/vConsole/3.3.4/vconsole.min.js"></script>
        <script src="https://cdn.bootcdn.net/ajax/libs/blueimp-md5/1.0.1/js/md5.js"></script>
        <script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
        <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
        <script>
            Math.uuid = (function () {
                var CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
                return function (len, radix) {
                    var chars = CHARS,
                        uuid = [],
                        rnd = Math.random;
                    radix = radix || chars.length;
                    if (len) {
                        for (var i = 0; i < len; i++) uuid[i] = chars[0 | rnd() * radix];
                    } else {
                        var r;
                        uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
                        uuid[14] = '4';
                        for (var i = 0; i < 36; i++) {
                            if (!uuid[i]) {
                                r = 0 | rnd() * 16;
                                uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r & 0xf];
                            }
                        }
                    }
                    return uuid.join('');
                };
            })();
        </script>
        <script>

            var BASE_URL = 'http://lzyptapi.szlzpt.com/tg/'
           

            document.getElementById('test').addEventListener('click', main)

            function main() {
                var redirect_uri = window.location.origin + window.location.pathname
                let appid = null
                var scope = 'snsapi_base'

                var accesstoken = null
                $.ajax({
                    url:BASE_URL+ 'sing',
                    type:'post',
                    headers:{
                        'Content-Type':'application/json'
                    },
                    dataType:'json',
                    data:JSON.stringify({url:redirect_uri}),
                    success:function(res){
                        console.log('res',res)
                        if(!res || res.code!=200 || !res.data) return
                        appid = res.data.appId
                        wx.config({
                            appId:res.data.appId,
                            timestamp:res.data.timestamp,
                            nonceStr:res.data.nonceStr,
                            signature:res.data.sign.toLocaleLowerCase(),
                            jsApiList:['chooseImage'],
                            success:function(conf){
                                console.log('11签名成功!!!!')
                            }
                        })
                        wx.ready(function(aaa){
                            console.log('ready',aaa)
                        })
                    }
                })
            }

        </script>
        <script>
            (function(){
                var appid = 'wx29fa867a7c5621c7'
                var appid = 'wx5cb5cf401e657aa6'
                var redirect_uri = 'http://h5.szlzpt.com/test_jssdk.html'
                var de_url = encodeURIComponent(redirect_uri)
                var url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+appid+'&redirect_uri='+de_url+'&response_type=code&scope=snsapi_base&state=123#wechat_redirect'
                window.location.href = url
            })()
        </script>
    </body>

</html>